/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.insurance.cis.connection;

/**
 *
 * @author TruongLQ
 */
public class JdbcConfig {

    public static final String DRIVER_CLASS = "jdbc.driver.class";
    public static final String PROTOCOL_PREFIX = "jdbc.url.protocol.prefix";
    public static final String PROTOCOL_HOST = "jdbc.url.protocol.host";
    public static final String PROTOCOL_PORT = "jdbc.url.protocol.port";
    public static final String DATABASE_NAME = "jdbc.url.properties.databaseName";
    public static final String USERNAME = "jdbc.username";
    public static final String PASSWORD = "jdbc.password";
    public static final String CONFIG_FILE = "config/jdbc.properties";
    String driverClass, protocolPrefix, protocolHost, protocolPort,
            databaseName, username, password;

    public JdbcConfig() {
        this.driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
        this.protocolPrefix = "jdbc:sqlserver://";
        this.databaseName = "CIS";
        this.protocolPort = "1433";
        this.protocolHost = "localhost";
        this.username = "sa";
        this.password = "";
    }

    public JdbcConfig(String host, String databaseName, String port, 
            String userName, String password) {
        this.driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
        this.protocolPrefix = "jdbc:sqlserver://";
        this.databaseName = databaseName;
        this.protocolPort = port;
        this.protocolHost = host;
        this.username = userName;
        this.password = password;
    }

    String buildUrl() {
        return protocolPrefix + protocolHost + ":" + protocolPort
                + ";" + "databaseName" + "=" + databaseName;
    }

    public String getDriverClass() {
        return driverClass;
    }

    public void setDriverClass(String driverClass) {
        this.driverClass = driverClass;
    }

    public String getProtocolPrefix() {
        return protocolPrefix;
    }

    public void setProtocolPrefix(String protocolPrefix) {
        this.protocolPrefix = protocolPrefix;
    }

    public String getProtocolHost() {
        return protocolHost;
    }

    public void setProtocolHost(String protocolHost) {
        this.protocolHost = protocolHost;
    }

    public String getProtocolPort() {
        return protocolPort;
    }

    public void setProtocolPort(String protocolPort) {
        this.protocolPort = protocolPort;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return DRIVER_CLASS + "=" + this.driverClass + "\n"
                + PROTOCOL_PREFIX + "=" + this.protocolPrefix + "\n"
                + PROTOCOL_HOST + "=" + this.protocolHost + "\n"
                + PROTOCOL_PORT + "=" + this.protocolPort + "\n"
                + DATABASE_NAME + "=" + this.databaseName + "\n"
                + USERNAME + "=" + this.username + "\n"
                + PASSWORD + "=" + this.password;
    }
}
